package com.lagou.filter;

import com.lagou.utils.IpUtils;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(urlPatterns = "/*", filterName = "MyWebFilter")
public class MyWebFilter implements Filter {
    
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        String remoteAddr = request.getRemoteAddr();
        String remoteHost = request.getRemoteHost();
        System.out.println(remoteHost);
        System.out.println(remoteAddr);
        IpUtils.setThreadLocalIp(remoteAddr);
        chain.doFilter(request,response);
    }
}